Exemple 2: Filtering and averaging data

First thing we need to do is to import the msJ package.

In [1]:
using msJ

We will use the same data set as in Example 1

In [2]:
using HTTP

data = download("https://raw.githubusercontent.com/ajgiuliani/msJ.jl/master/test/test.mzXML", 
                "~/Downloads/test.mzXML") ;

Now, using the info function of the msJpackage, we will see what is inside the file

In [3]:
info(data)
Out[3]:
4-element Array{String,1}:
 "6 scans"                
 "MS1+"                   
 "MS2+ 1255.5  CID(CE=18)"
 "MS3+ 902.33  PQD(CE=35)"
In [4]:
s = load(data) ;

Getting chromatograms is straightforward using the chromatogram method. We load the entiere chromatogram like this:

In [5]:
full_TIC = chromatogram(s)
Out[5]:
msJ.Chromatogram([0.1384, 0.7307, 2.1379, 3.7578, 4.3442, 5.7689], [5.08195e6, 9727.2, 11.3032, 4.8084e6, 12203.5, 4.84455], 5.08195e6)

We may also filter the data to first MS level:

In [6]:
MS1_TIC = chromatogram(s, msJ.Level(1))
Out[6]:
msJ.Chromatogram([0.1384, 3.7578], [5.08195e6, 4.8084e6], 5.08195e6)

Or we may get only the mass spectrometry data which have been aquirred under CID conditions:

In [7]:
CID_TIC = chromatogram(s, msJ.Activation_Method("CID"))
Out[7]:
msJ.Chromatogram([0.7307, 4.3442], [9727.2, 12203.5], 12203.5)

We can also extract the chromatogram for a specific precursor ion:

In [8]:
mz902_TIC = chromatogram(s, msJ.Precursor(902.33))
Out[8]:
msJ.Chromatogram([2.1379, 5.7689], [11.3032, 4.84455], 11.3032)

Let plot the chromatograms, using theGR backend:

In [9]:
using Plots
gr()
Out[9]:
Plots.GRBackend()

A recipe has also been defined for chromatogram data.

In [10]:
gr()
p1 = plot(full_TIC, label = "full tic")
p2 = plot(MS1_TIC, label = " MS1_TIC")
p3 = plot(CID_TIC, label = "CID_TIC")
p4 = plot(mz902_TIC, label = "mz902_TIC")

p = plot(p1, p2, p3, p4, layout = (4,1), size = (500,500))
Out[10]:
0.00 0.02 0.04 0.06 0.08 0 25 50 75 100 time (mins) Intensity (%) full tic 0.01 0.02 0.03 0.04 0.05 0.06 0 25 50 75 100 time (mins) Intensity (%) MS1_TIC 0.02 0.03 0.04 0.05 0.06 0.07 0 25 50 75 100 time (mins) Intensity (%) CID_TIC 0.04 0.05 0.06 0.07 0.08 0.09 0 25 50 75 100 time (mins) Intensity (%) mz902_TIC

Plots made using GR() may be saved to a file:

In [11]:
savefig(p, "~/Downloads/temp.png")

Average mass spectra may be obtained using the proper msfilter functions:

In [12]:
ms1 = msJ.average(s, msJ.Level(1))                              # MS1 scans
ms2_CID = msJ.average(s, msJ.Activation_Method("CID"))          # CID scans
ms2_PQD = msJ.average(s, msJ.Activation_Method("PQD"))          # PQD scans
ms2_1255 = msJ.average(s, msJ.Precursor(1255.5));               # Precursor m/z = 1255.5 scans

Mass spectra may be plotted the same way as chromatograms:

In [13]:
plotly()
p5 = plot(ms1, label = "MS", color = :blue)
p6 = plot(ms2_CID, label = "CID", color = :green)
p7 = plot(ms2_PQD, label = "PQD", color = :purple)
p8 = plot(ms2_1255, label = "mz 1255", color = :orange)
plot(p5, p6, p7, p8, layout = (4,1), size = (800,600))
Out[13]:
Plots.jl